# 2185. 统计包含给定前缀的字符串
# 给你一个字符串数组 words 和一个字符串 pref 。

# 返回 words 中以 pref 作为 前缀 的字符串的数目。

# 字符串 s 的 前缀 就是  s 的任一前导连续字符串。

#  

# 示例 1：

# 输入：words = ["pay","attention","practice","attend"], pref = "at"
# 输出：2
# 解释：以 "at" 作为前缀的字符串有两个，分别是："attention" 和 "attend" 。
# 示例 2：

# 输入：words = ["leetcode","win","loops","success"], pref = "code"
# 输出：0
# 解释：不存在以 "code" 作为前缀的字符串。
#  

# 提示：

# 1 <= words.length <= 100
# 1 <= words[i].length, pref.length <= 100
# words[i] 和 pref 由小写英文字母组成

# 来源：力扣（LeetCode）
# 链接：https://leetcode.cn/problems/counting-words-with-a-given-prefix
# 著作权归领扣网络所有。商业转载请联系官方授权，非商业转载请注明出处。


from time import time
from typing import List


class Solution:
    def prefixCount(self, words: List[str], pref: str) -> int:
        n= 0
        for i in words:
            if i.startswith(pref):
                n+=1
        return n
    

if __name__ == '__main__':
    start = time()
    a = Solution()
    print(a.prefixCount(words = ["leetcode","win","loops","success"], pref = "code"))
    print(a.prefixCount(words = ["pay","attention","practice","attend"], pref = "at"))
    end = time()
    print('='*40)
    print("start time is ", start*1000)
    print("end   time is ", end*1000)
    print("耗时:",end*1000 - start*1000,"ms")